#include <p32xxxx.h>
#include "board.h"
#include "math.h"


// SSD1289 functions
void pmpInit(void);
void lcdInit(void);
void lcdBlInit(unsigned int brightness);
void lcdBlSetBrightness(unsigned int brightness);

void lcdSetAddress(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
void lcdSetPixel(unsigned int x, unsigned int y, unsigned int color);

// PMP Addresses. Bit 15 = CS2, Bit 14 = CS1, Bits 13-0 = ADDR<13:0>
#define DATA        0x4001
#define COMMAND     0x4000

// These functions are defined as macros and will be compiled in-line to help
// speed up execution.
#define lcdSendCommand(command, data) lcdWriteCom(command); lcdWriteData(data);
#define lcdWriteCom(command) PMADDR = COMMAND; PMDIN = command;
#define lcdWriteData(data) PMADDR = DATA; PMDIN = data;

// Colour definitions
#define	BLACK	0x0000
#define	RED	0xf800
#define ORANGE  0xff00
#define	GREEN	0x07e0
#define	BLUE	0x001f
#define	WHITE	0xffff
#define PURPLE	0xf11f
#define YELLOW	0xffe0
#define	CYAN	0x07ff


